package com.udf.hive.udf;


import com.udf.hive.unit.StringUtils;
import org.apache.hadoop.hive.ql.exec.UDF;

public class IdNum2Country extends UDF {
    private static IdNum2Address idNum2Address = new IdNum2Address();

    public String evaluate(String input) {
        String addrStr = idNum2Address.evaluate(input);
        String countyStr = StringUtils.parseCounty(addrStr);
        if (countyStr.equals("辖区")) {
            return "市" + countyStr;
        } else if (countyStr.trim().length() == 1) {
            return "";
        } else {
            return countyStr;
        }
    }

    public static void main(String[] args) {
        IdNum2Country idNum2City = new IdNum2Country();
        System.out.println(idNum2City.evaluate("411424198905256630"));
    }
}
